// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sysin

import (
	"context"
	"hotgo/internal/consts"
	"hotgo/internal/library/hgorm/hook"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"
	"hotgo/utility/validate"

	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

// AuctionUpdateFields 修改竞拍活动字段过滤
type AuctionUpdateFields struct {
	Name      string      `json:"name"      dc:"活动名称"`
	StartDate *gtime.Time `json:"startDate" dc:"开始日期"`
	EndDate   *gtime.Time `json:"endDate"   dc:"结束日期"`
	Status    int         `json:"status"    dc:"状态"`
	Enabled   int         `json:"enabled"   dc:"是否开启"`
}

// AuctionInsertFields 新增竞拍活动字段过滤
type AuctionInsertFields struct {
	Name      string      `json:"name"      dc:"活动名称"`
	StartDate *gtime.Time `json:"startDate" dc:"开始日期"`
	EndDate   *gtime.Time `json:"endDate"   dc:"结束日期"`
	//Status    int         `json:"status"    dc:"状态"`
	Enabled   int   `json:"enabled"   dc:"是否开启"`
	CreatedBy int64 `json:"createdBy" dc:"创建人"`
}

// AuctionEditInp 修改/新增竞拍活动
type AuctionEditInp struct {
	entity.Auction
}

func (in *AuctionEditInp) Filter(ctx context.Context) (err error) {
	// 验证活动名称
	if err := g.Validator().Rules("required").Data(in.Name).Messages("活动名称不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证开始日期
	if err := g.Validator().Rules("required").Data(in.StartDate).Messages("开始日期不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证结束日期
	if err := g.Validator().Rules("required").Data(in.EndDate).Messages("结束日期不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	return
}

type AuctionEditModel struct{}

// AuctionDeleteInp 删除竞拍活动
type AuctionDeleteInp struct {
	Id interface{} `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *AuctionDeleteInp) Filter(ctx context.Context) (err error) {
	return
}

type AuctionDeleteModel struct{}

// AuctionViewInp 获取指定竞拍活动信息
type AuctionViewInp struct {
	Id int64 `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *AuctionViewInp) Filter(ctx context.Context) (err error) {
	return
}

type AuctionViewModel struct {
	entity.Auction
	CreatedBySumma *hook.MemberSumma `json:"createdBySumma" dc:"创建人摘要信息"`
}

// AuctionListInp 获取竞拍活动列表
type AuctionListInp struct {
	form.PageReq
	Name      string        `json:"name"      dc:"活动名称"`
	Status    int           `json:"status"    dc:"状态"`
	CreatedAt []*gtime.Time `json:"createdAt" dc:"创建时间"`
}

func (in *AuctionListInp) Filter(ctx context.Context) (err error) {
	return
}

type AuctionListModel struct {
	Id             int64             `json:"id"             dc:"id"`
	Name           string            `json:"name"           dc:"活动名称"`
	StartDate      *gtime.Time       `json:"startDate"      dc:"开始日期"`
	EndDate        *gtime.Time       `json:"endDate"        dc:"结束日期"`
	Status         int               `json:"status"         dc:"状态"`
	Enabled        int               `json:"enabled"        dc:"是否开启"`
	CreatedAt      *gtime.Time       `json:"createdAt"      dc:"创建时间"`
	CreatedBy      int64             `json:"createdBy"      dc:"创建人"`
	CreatedBySumma *hook.MemberSumma `json:"createdBySumma" dc:"创建人摘要信息"`
	UpdatedAt      *gtime.Time       `json:"updatedAt"      dc:"更新时间"`
}

// AuctionExportModel 导出竞拍活动
type AuctionExportModel struct {
	Id        int64       `json:"id"        dc:"id"`
	Name      string      `json:"name"      dc:"活动名称"`
	StartDate *gtime.Time `json:"startDate" dc:"开始日期"`
	EndDate   *gtime.Time `json:"endDate"   dc:"结束日期"`
	Status    int         `json:"status"    dc:"状态"`
	Enabled   int         `json:"enabled"   dc:"是否开启"`
	CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
	CreatedBy int64       `json:"createdBy" dc:"创建人"`
	UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
}

// AuctionStatusInp 更新竞拍活动状态
type AuctionStatusInp struct {
	Id     int64 `json:"id" v:"required#id不能为空" dc:"id"`
	Status int   `json:"status" dc:"状态"`
}

func (in *AuctionStatusInp) Filter(ctx context.Context) (err error) {
	if in.Id <= 0 {
		err = gerror.New("id不能为空")
		return
	}

	if in.Status <= 0 {
		err = gerror.New("状态不能为空")
		return
	}

	if !validate.InSlice(consts.StatusSlice, in.Status) {
		err = gerror.New("状态不正确")
		return
	}
	return
}

type AuctionStatusModel struct{}

// AuctionSwitchInp 更新竞拍活动开关状态
type AuctionSwitchInp struct {
	form.SwitchReq
	Id int64 `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *AuctionSwitchInp) Filter(ctx context.Context) (err error) {
	return
}

type AuctionSwitchModel struct{}
